<?php

namespace Xrfg\Api\Consume\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
use Xrfg\Api\Consume\Models\ConsumeAccounts;
use Xrfg\Api\Consume\Observers\ConsumeAccountObserver;

class ServiceProvider extends IlluminateServiceProvider
{
    public function boot()
    {
        $this->registerObservers();
        $this->registerRoutes();
    }

    public function register()
    {
        $this->mergeConfigFrom(
            __DIR__.'/../../config/error.php',
            'error'
        );
    }

    private function registerRoutes()
    {
        Route::prefix('api/consume')
            ->middleware('api')
            ->namespace('Xrfg\\Api\\Consume\\Controllers')
            ->group(function () {
                $this->loadRoutesFrom(__DIR__.'/../../routes/api.php');
            });
    }

    private function registerObservers()
    {
        ConsumeAccounts::observe(ConsumeAccountObserver::class);
    }
}
